#include <work_queue_run.hpp>
#include <work_queue_utils.hpp>

static WorkQueueUtils* s_WorkQueueUtils = nullptr;

WorkQueueUtils* WorkQueueUtils::Instance()
{
	if (s_WorkQueueUtils == nullptr)
	{
		s_WorkQueueUtils = new WorkQueueUtils();
	}
	return s_WorkQueueUtils;
}

WorkQueueUtils::WorkQueueUtils()
{
}

WorkQueueUtils::~WorkQueueUtils()
{
}

void WorkQueueUtils::Start(int priority, int stackSize, int rate, const char* taskName, int cpuId)
{
	WorkQueueRun* wqRun = new WorkQueueRun(priority, stackSize, rate, taskName, cpuId);
	m_WQRuns[priority]	= wqRun;
	wqRun->Start();
}

void WorkQueueUtils::Append(int priority, WorkQueue* workQueue)
{
	if (workQueue == nullptr)
	{
		LOG("workQueue is null.\n");
		return;
	}

	WorkQueueRun* wqRun = m_WQRuns[priority];
	if (wqRun == nullptr)
	{
		LOG("wqRun is null.\n");
		return;
	}

	wqRun->Append(workQueue);
}